// 获取常用时间
import dayjs from 'dayjs';
import moment from 'moment-timezone'

export const LAST_7_DAYS = [
  dayjs().subtract(7, 'day').format('YYYY-MM-DD'),
  dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
];

export const LAST_30_DAYS = [
  dayjs().subtract(30, 'day').format('YYYY-MM-DD'),
  dayjs().subtract(1, 'day').format('YYYY-MM-DD'),
];

// 处理时区
export const formatByMomentTimezone = (time:string|Date) => {
  // console.log('Time:', time)
  // set true：not get Cache
  let timezoneName = moment.tz.guess(true);
  // 首先调用 Intl.DateTimeFormat().resolvedOptions().timeZone
  // console.log('timezoneName', timezoneName)
  const resDate = moment.tz(time, timezoneName)?.format('YYYY-MM-DD HH:mm:ss');
  return resDate || '';
}